#include "descriptorManager.h"
#include "common.h"
#include "termlist.h"



int main(int argc, char** argv) {
  log_init();
  g_log_context.log_level = LOG_DEBUG;
  int ret;

  FILE* fp = fopen(argv[1], "r");assert(fp);

  tl_head_t head;
  tl_term_t term;
  offset_t  off;

  while(1) {
    ret = fread(&head, sizeof(tl_head_t), 1, fp);
    if(ret != 1) {
      if(feof(fp)){
	exit(0);
      }
      else {
        assert(0);
      }
    }
    WARNING("---head: id:%d num_term:%d---",
	head.id, head.num_term);
    for(int i = 0 ; i < head.num_term ; ++i) {
      ret = fread(&term, sizeof(tl_term_t), 1, fp);
      assert(ret == 1);
      WARNING("\tterm[%llu] w[%u] num_off[%d]", 
	  term.sign, term.weight, term.num_off);
      for(int j = 0 ; j < term.num_off ; ++j) {
        ret = fread(&off, sizeof(offset_t), 1, fp);
	assert(ret == 1);
	WARNING("\t\toff[%d][%d]", off.texttype, off.offset);
      }
    }
  }
  
  return 0;
}

